//
// Created by ChenJi on 2022/1/5.
//
#include <string.h>
#include "AirSensor.h"
#include "ZigbeeDevice.h"

uint8_t current_dat[16];

uint8_t valid_data = 0;

void airSensorInit() {
    for (uint8_t i = 0; i < 14; i++) {
        current_dat[i] = 0;
    }
    current_dat[0] = 0x01;
    current_dat[1] = valid_data;

    valid_data = 0;

}

void onUart2Message(uint8_t *data, uint16_t size) {
    if (*data == 0x3C && *(data + 1) == 0x02) {
        memcpy(current_dat + 2, data + 2, 14);
        valid_data = 1;
        current_dat[0] = valid_data;
    }
}

void sendAirDataToTerminal() {
    replyToTerminal(current_dat,16);
}
